#include <bits/stdc++.h>

using namespace std;

struct Node {
public:
  int val;
  Node *l;
  Node *r;
  Node(int val_ = 0, Node *l_ = nullptr, Node *r_ = nullptr)
      : val(val_), l(l_), r(r_) {
    ;
  }
  /* data */
};
typedef Node *Tree;
class BST {
public:
    Tree root;
    BST(vector<int> & nums){
        root = nullptr;
        for(auto num:nums){
            insert(num);
        }
    }
    void insert(int val){
        Tree *pnode = &root;
        for(;*pnode;){
            if((*pnode)->val < val){
                pnode = &((*pnode)->r);
            }
            else{
                pnode = &((*pnode)->l);
            }
        }
        *pnode = new Node(val);
    }

    void Preprint(){
        helpPrePrint(this->root);
        cout << endl;
    }
    void helpPrePrint(Node *node){
        if(node == nullptr) return;
        cout << node->val << " ";
        helpPrePrint(node->l);
        helpPrePrint(node->r);
    }
};

int main() {
  vector<int> nums;
  string readed;
  getline(cin, readed);
  stringstream thisline(readed);
  int num;
  while (thisline >> num) {
    nums.push_back(num);
  }
  BST bst(nums);
  bst.Preprint();
}